package com.wc.blue_bridge_history.Java14Q.E_互质数的个数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/24 19:44
 * @description https://www.lanqiao.cn/paper/3874/problem/3522/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static long a, b;
    static int P = 998244353;

    public static void main(String[] args) {
        a = sc.nextInt();
        b = sc.nextLong();
        if (a == 1) {
            System.out.println(0);
            return;
        }
        long res = a;
        long t = a;
        //  1 <= x < a ^ b的个数为， a = p1 ^ b1 * p2 ^ b2互质的个数为 a * (p1 - 1)/ p1 * (p2 - 1)/ p2 * ...
        //  a ^ b 次方, a ^ b * (...) a ^ (b - 1) * a * (...)
        for (int i = 2; (long) i * i <= t; i++) {
            if (t % i == 0) {
                res = res * (i - 1) / i % P;
                while (t % i == 0) {
                    t /= i;
                }
            }
        }
        if (t > 1) {
            res = res * (t - 1) / t % P;
        }
        System.out.println(qkm(a, b - 1) * res % P);
    }

    static long qkm(long a, long b) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1) res = res * a % P;
            a = a * a % P;
            b >>= 1;
        }
        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
